'use client';

import EditableTable from '@/pao/web/dataEdit/dateEditEditableTable';
import { Student } from '@/data/prisma';
import { ProColumnType } from '@ant-design/pro-components';

import { addRow, deleteRow, editRow, query } from './service';

const columns: ProColumnType<Student>[] = [
    {
        title: '编号',
        dataIndex: 'code',
        fixed: 'left',
        sorter: true,
        width: '80px',
    },
    {
        title: '名称',
        dataIndex: 'name',
        sorter: true,
        fixed: 'left',
        width: '150px',
    },
    {
        title: '性别',
        dataIndex: 'gender',
        sorter: true,
        width: '80px',
				valueType: 'select',
				valueEnum: {
					'男': '男',
					'女': '女',
				}
    },
    {
        title: '生日',
        dataIndex: 'birthday',
        sorter: true,
        width: '150px',
				valueType: 'date',
    },
    {
        title: '微信',
        dataIndex: 'wechatId',
        sorter: true,
        width: '150px',
    },
    {
        title: 'QQ',
        dataIndex: 'qq',
        sorter: true,
        width: '150px',
    },
    {
        title: 'Email',
        dataIndex: 'email',
        sorter: true,
        width: '150px',
    },
    {
        title: '电话',
        dataIndex: 'phone',
        sorter: true,
        width: '150px',
    },
    {
        title: '备注',
        dataIndex: 'comments',
        sorter: true,
        width:'auto',
    },
];

const config = {
    headerTitle: '学生',
    tooltip: '修改学生信息',
}

export default function StudentControl() {
    return <EditableTable<Student> columns={columns} rowKey="id" config={config} deleteRow={deleteRow} query={query} editRow={editRow} addRow={addRow}/>
}